package logic

import (
	"context"
	"doctor-medicine-system/mysql/models"

	"doctor-medicine-system/doctorrpc/doctorrpc"
	"doctor-medicine-system/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
	return &ListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 列表
func (l *ListLogic) List(in *doctorrpc.ListRequest) (*doctorrpc.ListResponse, error) {
	// todo: add your logic here and delete this line

	var shop models.Shop

	var shops []*doctorrpc.ShopList

	list, err := shop.ShopList(models.DB, shops)
	if err != nil {
		return nil, err
	}

	return &doctorrpc.ListResponse{
		List: list,
	}, nil
}
